package com.hl.card.modular.packBack.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.plugins.Page;
import com.hl.card.common.persistence.dao.HotelOrderMapper;
import com.hl.card.common.persistence.model.HotelOrder;
import com.hl.card.modular.packBack.service.HotelOrderService;

@Service
public class HotelOrderServiceImpl  implements HotelOrderService<HotelOrder>{
    
	@Autowired
	private HotelOrderMapper hotelOrderMapper;
	
	@Override
	public List<HotelOrder> list(Page<HotelOrder> page,HotelOrder  order) {
		int skip = (page.getCurrent() - 1) * page.getSize();
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("offset", skip);
        map.put("size", page.getSize());
        if(!StringUtils.isEmpty(order.getOrder_number()))
        {
        	  map.put("order_number", order.getOrder_number());
        }
        if(!StringUtils.isEmpty(order.getApi_order_number()))
        {
        	  map.put("api_order_number", order.getApi_order_number());
        }
        if(!StringUtils.isEmpty(order.getPhone()))
        {
        	  map.put("phone", order.getPhone());
        }
        if(order.getStatus()!=null&&!order.getStatus().equals(0))
        {
        	  map.put("status", order.getStatus());
        }
        if(!StringUtils.isEmpty(order.getStart_time())&&!StringUtils.isEmpty(order.getEnd_time()))
        {
        	 map.put("start_time", order.getStart_time()+" 00:00:00");
        	 map.put("end_time", order.getEnd_time()+" 59:59:59");
        }
        page.setTotal(hotelOrderMapper.listCount(map));
		return hotelOrderMapper.list(map);
	}

	@Override
	public List<HotelOrder> exPort(Map<String, Object> map) {
		return hotelOrderMapper.exPort(map);
	}

}
